1
|
|
|
/* eslint-env es6, deno */ |
2
|
|
|
// # spell-checker:ignore Deno |
3
|
|
|
|
4
|
|
|
/* eslint-disable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/ban-ts-comment , @typescript-eslint/no-explicit-any */ |
5
|
|
|
|
6
|
|
|
// @ts-ignore |
7
|
|
|
import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@latest/src/mod.deno.ts'; |
8
|
|
|
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths/src/mod.deno.ts'; |
9
|
|
|
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@6/src/mod.deno.ts'; |
10
|
|
|
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/[email protected]/src/mod.deno.ts'; |
11
|
|
|
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@2d5924e692617a575c8a73c9fb611e93085c4339/src/mod.deno.ts'; |
12
|
|
|
|
13
|
|
|
// create a local reference to refer to `Deno` (for better linting without need for multiple `// @ts-ignore` directives) |
14
|
|
|
// @ts-ignore |
15
|
|
|
const deno = Deno; |
16
|
|
|
|
17
|
|
|
function objectEntries(obj: any) { |
18
|
|
|
const map: any = {}; |
19
|
|
|
Object.keys(obj).forEach((key) => { |
20
|
|
|
const value = obj[key]; |
21
|
|
|
const val = typeof value === 'function' ? value() : value; |
22
|
|
|
map[key] = val; |
23
|
|
|
}); |
24
|
|
|
return map; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
console.log({ osPaths }); |
28
|
|
|
console.log(objectEntries(osPaths)); |
29
|
|
|
console.log('home() =', osPaths.home()); |
30
|
|
|
console.log('temp() =', osPaths.temp()); |
31
|
|
|
|
32
|
|
|
deno.env.set('TEMP', 'temp'); |
33
|
|
|
deno.env.set('TMPDIR', 'tmpdir'); |
34
|
|
|
deno.env.set('TMP', 'tmp'); |
35
|
|
|
console.log(objectEntries(osPaths)); |
36
|
|
|
|
37
|
|
|
deno.env.set('TEMP', 'NEW'); |
38
|
|
|
console.log(objectEntries(osPaths)); |
39
|
|
|
|
40
|
|
|
/* eslint-enable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/ban-ts-comment , @typescript-eslint/no-explicit-any */ |
41
|
|
|
|